home *** CD-ROM | disk | FTP | other *** search
- #pragma once /*prevents multiple inclusions of this file */
-
- #include "CParticle.h"
- #include "FlockUtils.h" // handy vector and QuickDraw routines and stuff
-
- #define kIDOffset 1000 // resource id offset to add to BoidType
-
- /* The possible values for fScreenCtl */
- #define kDeepScr 1
- #define kBigScr 2
- #define kAllScr 3
-
- typedef struct
- {
- // Average neighbor info
- long fNum; // how many neighbors
- FloatPoint fAvgPos;
- FloatPoint fAvgVel;
- double fAvgDistSquared;
-
- // Nearest Neighbor info
- FloatPoint fNearestPos;
- double fNearestDistSquared;
- }NeighborRec; // size = 34 bytes
-
- class CBoid : CParticle
- {
- public:
- NeighborRec fNaybs; // CFlock sets this up each step
- long fCurrentFrame; // The current frame of the animation: each boid needs its own
- CBoid *InitBoid(Rect *worldRect, Handle theBits, Handle theMaskBits, Point position);
-
- void Move( FloatPoint *newPos,
- Rect *worldRect,
- ControlRec *controls,
- double comfydistsq);
-
- void GetBoidPos(FloatPoint *pos);
- void GetBoidVel(FloatPoint *vel);
-
- Boolean HeadHome(void);
- void Nudge(void);
- Boolean fHome;
-
- private:
- Handle fTheMap;
- RgnHandle fTheMaskRgn;
- Ptr fTheBits;
- Point fStartPoint;
-
- OSErr InitBits(Handle theBits, Handle theMaskBits);
-
-
- void Reset(void);
- void NewAccel(double comfydistsq, ControlRec *controls);
- void RunAway(double comfydistsq, FloatPoint *request);
- void MatchVel(FloatPoint *request);
- void CatchUp(FloatPoint *request);
- };
-